<!DOCTYPE html>
<html>

	<head>
		<title>个人页面</title>
		<meta charset="utf-8"/>
		<meta name="viewport" content="width=device-width, initial-scale=1, shrink-to-fit=no">
		<link rel="stylesheet" href="/js/bootstrap/css/bootstrap.min.css">
		<script src="/js/jquery/jquery.min.js"></script>
		<script src="/js/bootstrap/js/bootstrap.min.js"></script>
		<link rel="stylesheet" href="/css/font/css/font-awesome.min.css">
		<link rel="stylesheet" href="/css/reset.css"/>
		<link rel="stylesheet" href="/css/userProfiles.css"/>
		<script src="/js/plugins/jrender/jrender.min.js"></script>
		<link rel="stylesheet" href="/js/plugins/dialog2/dialog.css">
		<script src="/js/plugins/dialog2/dialog.min.js"></script>
        <script src="js/common.js"></script>
    </head>
	<body>
		<div class="container bg" style="background-image: url('/img/user/bg.jpeg');">
			<a href="javascript:window.history.go(-1)" class="my-arrow">
				<span><i class="fa fa-chevron-left fa-2x"></i></span>
			</a>
			<div class="container">
				<div class="info">
					<img class="rounded-circle" width="20%" render-src="headImgUrl">
					<p class="name" render-html="nickName"></p>
					<p render-html="sign"></p>


					<div class="row num">
						<div class="col-2 border border-left-0 border-top-0 border-bottom-0">
							<div>
								<span render-html="follows">1</span>
							</div>
							<div>
								<span >关注</span>
							</div>
						</div>
						<div class="col-2">
							<div>
								<span render-html="fans">0</span>
									</div>
							<div>
								<span>粉丝</span>
							</div>
						</div>
						<div class="col">
							<button class="btn btn-outline-light ibtn" id="letterBtn">私信</button>
							<button class="btn btn-success ibtn" id="followBtn">关注</button>
						</div>
					</div>
				</div>
			</div>
		</div>

		<div class="tabs">
			<ul class="nav nav-pills nav-justified  border border-left-0 border-top-0 border-right-0" id="pills-tab" role="tablist">
				<li class="nav-item">
					<a class="nav-link active" id="travels-tab" data-toggle="pill" href="#travels">
						TA的游记[<span>1</span>]
					</a>
				</li>
				<li class="nav-item">
					<a class="nav-link " id="comments-tab" data-toggle="pill" href="#comments">
						TA的点评[<span>1</span>]
					</a>
				</li>
				<li class="nav-item">
					<a class="nav-link" id="pills-contact-tab" data-toggle="pill" href="#pills-contact">
						TA的旅行单[<span>0</span>]
					</a>
				</li>
			</ul>
			<div class="container tab-content" id="pills-tabContent">
				<div class="tab-pane fade show active" id="travels">
					<dl class="list" render-loop="list">
						<dd>
							<a href="/travelContent.html?id=" render-fun="setHref" render-key="list.id" data-id="2"	>
								<img  render-src="list.coverUrl">
								<p><span class="title" render-html="list.title"></span>
									<span class="span-right">
									<span >0</span> <i class="fa fa-thumbs-o-up"></i></span>
								</p>
							</a>
							<hr>
						</dd>
					</dl>
				</div>

				<div class="comment tab-pane fade " id="comments">
					<div>
						<div class="row">
							<div class="col-2 comment-head">
								<img  class="rounded-circle" src="/upload/7e854d1d-a7be-4360-8943-8771d18ee0e3.jpg">
							</div>
							<div class="col">
								<span class="comment-star" ><i class="fa fa-star"></i><i class="fa fa-star"></i><i class="fa fa-star"></i><i class="fa fa-star-o"></i><i class="fa fa-star-o"></i></span>

								<span class="comment-date" >2018-07-11</span>
								<div class="comment-content">
									<a href="/strategyComment.html"  data-id="4">
										<p >骑了个单车到沙面，春风把从上下九和宝华路带来的燥热吹散。沙面临江，下午的时光让这富有异国风情的公园显得更加宁静惬意，哪怕...</p>
									</a>
								</div>
								<ul class="comment-img"><li>
										<img  src="/upload/63bb765d-5dff-44f8-b7f1-cb338b9b9f95.jpeg">
									</li><li>
										<img  src="/upload/7d437f8d-a476-465c-bd84-e93a03d8efd5.jpeg">
									</li></ul>

								<div class="comment-link">
									<a href="strategyCatalogs.html" data-id="2">
										<img  src="/upload/e5e8a1a7-b127-4145-9fd0-a94e29f752ba.jpeg"> <span >广州攻略</span>
										<i class="fa fa-angle-right fa-2x"></i>
									</a>
								</div>
							</div>
						</div>
					</div>
				</div>
				<div class="tab-pane fade" id="pills-contact">
					<p>
						广州塔是广州的地标性景点，坐落在珠江沿岸，与广州商业中心“珠江新城”隔江相望。
						广州塔自2010年落成以来便以600米的绝对高度摘下了中国第一高塔的桂冠。
						在这样一座高耸的观光塔顶部有着多项吉尼斯世界纪录项目。
						其中包括423米的世界最高旋转餐厅；488米的世界最高户外观景平台；454米的世界最高摩天轮及485米的世界最高跳楼机（自由落体距离30米）。
						无数精彩的观光、娱乐项目给来广州塔游玩的游客带来了精彩纷呈的高空体验，让游客感受一把“触及”天际的非凡之旅。
					</p>
				</div>
			</div>
		</div>

	<script>
		$(function () {
		    //渲染当前作者页面信息
		    var author = getParams();
		  var  aid = author.id;
            console.log(aid);
            $.get("/users",{userId:author.id}, function (data) {
                $(".info").renderValues(data)
                // $(".bg").css("background-image","url('"+data.coverImgUrl+"')");
            });



            //回显个人信息页面----------------------------------------------------
            var userStr = sessionStorage.getItem("user");
            var user = JSON.parse(userStr);
            console.log(user);
            var uid = user.id;
            console.log(uid);
            // console.log(user);
            // $(".info").renderValues(user);
            //
            // //设置背景墙,添加样式-------------------------------------------------
            // $(".bg").css("background-image","url('"+user.coverImgUrl+"')")

            //点击Ta的游记.跳转功能(包含滑动分页功能)--------------------------------
            var dataList=[];
            var currentPage =1;
            var totalPage=0;

			function query() {
                $.get("/users/"+author.id+"/travels",{currentPage:currentPage,pageSize:5},function (data) {
                    console.log(data);
                    $.merge(dataList,data.list);
                    $("#travels").renderValues({list:dataList},{
                        setHref:function (item, value) {
                            var href =$(item).attr("href")+value;
                            $(item).attr("href",href);
                        }
                    });
                    currentPage +=1;
                    totalPage = data.pages;
                })
            }

            //滑动分页-----------------------------------------------------------
            //分页的条件:屏幕的高度+滑动的高度>=文档的高度
            query();

            $(window).scroll(function () {
                if($(window).height()+$(window).scrollTop()>=$(document).height()){
                    if(currentPage<=totalPage){
                       query();
                    }else{
                        $(document).dialog({
                            type : 'notice',
                            infoText: '亲.我也是有限度的',
                            autoClose: 2500,
                            position: 'bottom'  // center: 居中; bottom: 底部
                        });
                    }
                }
            })
            //关注与粉丝-----------------------------------------------------------
    		//点击关注
            $.get("/users/relations", {userId: uid, authorId: aid}, function (data) {
                console.log(data);
                if (data) {
                    $("#followBtn").html(a);
                }else {
                    $("#followBtn").html(b);
                }
            });

            var a = '已关注';
            var b = '关注';
            $("#followBtn").click(function () {
                $.ajax({
                    type: "PUT",
                    url: "/users/changeFans",
                    data: {userId:uid,authorId:aid},
                    success: function(){
                        $.get("/users/relations", {userId: uid, authorId: aid}, function (data) {
                            if (data) {
                                $("#followBtn").html(a);
                            }else {
                                $("#followBtn").html(b);
                            }
                            $.get("/users",{userId:author.id}, function (data) {
                                $(".info").renderValues(data)
                                // $(".bg").css("background-image","url('"+data.coverImgUrl+"')");
                            });
                        });
                    }
                });



            });
        })


	</script>


</body>
</html>